# -*- coding: utf-8 -*-
"""
Created on Fri Feb  9 16:31:55 2024

@author: José Iván Cambón Bouzas
"""

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.signal import find_peaks
from scipy.signal import argrelextrema


#U2 = ["0.4","0.7", "1", "1.5","2"]

files = ["datos_1V.csv"]
dfs = [pd.read_csv(file, sep="\s+", decimal=",") for file in files]

colors = ["b", "r", "g","k","orange"]
labels = ["U2 = 1 V"]


plt.figure(1)
for df, color, label in zip(dfs, colors, labels):
    plt.plot(df["U1/V"], df["IA/nA"], "{0}".format(color), label=label )
plt.xlabel("V1 (V)")
plt.ylabel("I (nA)")
plt.legend()


df = dfs[0]
I = np.array(df["IA/nA"])
V = np.array(df["U1/V"])

peaks = argrelextrema(I, np.greater)

plt.figure(2)
plt.plot(df["U1/V"], df["IA/nA"], "{0}".format(colors[0]), label=label[0])
plt.plot(V[peaks], I[peaks], 'r*')

plt.show()
#plt.savefig('1V.png')